<%@page import="com.bf.entity.Admin"%>
<%@page import="com.bf.entity.Role"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'showAdd.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<link rel="stylesheet" type="text/css" href="admin/resource/css/wzgl.css" />
    <link rel="stylesheet" type="text/css" href="admin/resource/css/global.css" />
    <script type="text/javascript">
        function getRole() {
          <%
            List<Role> allRoles = (List<Role>)request.getAttribute("roles");
            Admin admin = (Admin)request.getAttribute("admin");
            for(Role allRole : allRoles) {
              for(Role adminRole : admin.getRoleSet()) {
                if(allRole.getId().equals(adminRole.getId())) {
                   %>
                   document.getElementById("<%=adminRole.getId()%>").checked=true;
                   <%
                }
              }
            }
          %>
        }
    </script>
  </head>
  
  <body class="body" onload="getRole()">
   <div class="w_100 title_all box"><div class="return"><a href="javascript:history.back(-1)">返回</a></div></div>
	<div class="w_100 right_all center box">
		<!--添加账号-->
		<div class="right_lm_xglm box">
			<form action="admin/admin_update.action" method="post" id="f1">
				<input type="hidden" name="id" value="${admin.id}">
				<ul>
					<li><span>账号：</span><input type="text" name="admin.account" id="account" value="${admin.account}"/>
					</li>
					<li><span>密码：</span><input type="text" name="admin.password" id="password" value="${admin.password}"/>
					</li>
					<li><span>姓名：</span><input type="text" name="admin.empName" id="empName" value="${admin.empName}"/>
					</li>
					<li class="ck">
					<span>角色：</span>
					    <c:forEach items="${roles}" var="flag">
					    <input type="checkbox" name="roleIds" value="${flag.id}" id="${flag.id}">${flag.name}
					    </c:forEach>
					</li>
				</ul>
			<div class="xgnr_sub">
				<input type="reset" value="重置" /> <input type="submit" value="提交"/>
			</div>
			</form>
		</div>
	</div>
</body>
</html>
